<template>
  <section class="jumbotron">
      <h3 class="jumbotron-heading">Search Github Users</h3>
      <div>
        <input 
        type="text" 
        placeholder="enter the name you search"
        v-model="searchInfo"
        />
        <button @click="searchHandle">Search</button>
      </div>
    </section>
</template>

<script>
import axios from 'axios'
export default {
name:'Header',
props:['getHeaderHandle'],
data(){
    return{
        searchInfo:'',
    }
},
methods: {
    
   async searchHandle(){
    await this.getHeaderHandle({isInit:true,isSearch:false})
    const result=await axios.get(`https://api.github.com/search/users?q=${this.searchInfo}`)
    // console.log(result);
    //请求成功
    this.getHeaderHandle({isSearch: false, userList: result.data.items,isInit:false})
    }
},
}
</script>

<style>

</style>